﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
namespace Presentation
{
    public partial class RPTongKetHocKy : Form
    {
        DataTable hocky, DSThongTin;
        public RPTongKetHocKy()
        {
            InitializeComponent();
        }

        private void button_thoat_Click(object sender, EventArgs e)
        {
            this.Hide();
        }
        
        private void TaoHocKy()
        {
            hocky = new DataTable();
            DataColumn ten = new DataColumn("Học Kỳ", typeof(string));
            DataColumn giatri = new DataColumn("Mã HK", typeof(int));
            hocky.Columns.Add(ten);
            hocky.Columns.Add(giatri);
            DataRow giatri0 = hocky.NewRow();
            giatri0[0] = "Chọn Học Kỳ";
            giatri0[1] = -1;
            hocky.Rows.Add(giatri0);
            DataRow giatri1 = hocky.NewRow();
            giatri1[0] = "Học Kỳ I";
            giatri1[1] = 1;
            hocky.Rows.Add(giatri1);
            DataRow giatri2 = hocky.NewRow();
            giatri2[0] = "Học Kỳ II";
            giatri2[1] = 2;
            hocky.Rows.Add(giatri2);
        }
        private void LayHK()
        {
            TaoHocKy();
            comboBox_hk.DataSource = hocky;
            comboBox_hk.DisplayMember = "Học Kỳ";
            comboBox_hk.ValueMember = "Mã HK";
        }

        private void RPTongKetHocKy_Load(object sender, EventArgs e)
        {
            LayHK();
        }

        private void button_xem_Click(object sender, EventArgs e)
        {
            if (int.Parse(comboBox_hk.SelectedValue.ToString().Trim()) != -1)
            {
                DSThongTin = BUSTongKetHocKy.DSThongTin(int.Parse(comboBox_hk.SelectedValue.ToString().Trim()));
                DataColumn col = new DataColumn("STT");
                DSThongTin.Columns.Add(col);
                for (int i = 0; i < DSThongTin.Rows.Count; i++)
                {
                    DSThongTin.Rows[i]["STT"] = i + 1;
                }
                dataGridView_dstt.DataSource = DSThongTin;
                dataGridView_dstt.Columns["STT"].DisplayIndex = 0;
                dataGridView_dstt.Columns["STT"].Width = 40;
                dataGridView_dstt.Columns["tenlop"].HeaderText = "Tên Lớp";
                dataGridView_dstt.Columns["tenlop"].Width = 80;
                dataGridView_dstt.Columns["siso"].HeaderText = "Sỉ Số";
                dataGridView_dstt.Columns["siso"].Width = 70;
                dataGridView_dstt.Columns["soluongdat"].HeaderText = "Số Lượng Đạt";
                dataGridView_dstt.Columns["soluongdat"].Width = 110;
                dataGridView_dstt.Columns["tyle"].HeaderText = "Tỷ lệ %";
                dataGridView_dstt.Columns["tyle"].Width = 78;
            }
        }
    }
}
